﻿using System;
using System.Collections.Generic;
using System.Collections;
using System.Linq;
using System.Text;
using Borland.Studio.ToolsAPI;

namespace SimpleDelphiExpert
{
    public abstract class FileHistoryProvider : IOTAFileHistoryProvider
    {
        private bool isConnected = false;

        protected abstract bool DoConnect();
        protected virtual void DoDisconnect() { }
        protected abstract IOTAFileHistory DoGetFileHistory(string AFileName);

        public FileHistoryProvider()
        {
            Connect();
        }

        ~FileHistoryProvider()
        {
            Disconnect();
        }

        public void Connect()
        {
            if (isConnected)
                return;

            isConnected = DoConnect();
        }

        public void Disconnect()
        {
            DoDisconnect();
            isConnected = false;
        }

        public IOTAFileHistory GetFileHistory(string AFileName)
        {
            Connect();
            return DoGetFileHistory(AFileName);
        }

        public abstract string Ident
        {
            get;
        }

        public abstract string Name
        {
            get;
        }
    }
}
